﻿<%@ Page Language="C#" %>

function Hashtable() {
	this.table = new Array();

	// Clears this hashtable so that it contains no keys. 
	this.clear = function() {
		var keys = this.keys();
		
		for(var i=0; i<keys.length; i++) {
			this.remove(keys[i]);
		}
	}

	// Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method.
	// Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework). 
	this.contains = function() {
		return this.containsValue(arguments[0]);
	}

	// Tests if the specified object is a key in this hashtable. 
	this.containsKey = function() {
		var keys = this.keys();

		for(var i=0; i<keys.length; i++) {
			if( keys[i]==arguments[0] )
				return true;
		}

		return false;
	}

	// Returns true if this Hashtable maps one or more keys to this value.
	// Note that this method is identical in functionality to contains (which predates the Map interface). 
	this.containsValue = function() {
		var values = this.values();

		for(var i=0; i<values.length; i++) {
			if( values[i]==arguments[0] )
				return true;
		}
		return false;
	}

	// Returns the value to which the specified key is mapped in this hashtable. 
	this.get = function() {
		return this.table[arguments[0]];
	}
	
	// Returns an enumeration of the keys in this hashtable. 
	this.keys = function() {
		var keys = new Array();
		for(var itr in this.table) {
			keys = keys.concat(itr);
		}
		
		return keys;
	}

	// Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null. 
	// The value can be retrieved by calling the get method with a key that is equal to the original key. 
	this.put = function() {
		this.table[arguments[0]] = arguments[1];
	}


	// Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable. 
	this.remove = function() {
		var delObj = this.table[arguments[0]];
		delete this.table[arguments[0]];
		return delObj;
	}

	// Returns a Collection view of the values contained in this Hashtable. The Collection is backed by the Hashtable, so changes to the Hashtable are reflected in the Collection, and vice-versa. The Collection supports element removal (which removes the corresponding entry from the Hashtable), but not element addition. 
	this.values = function() {
		var keys = this.keys();
		var values = new Array();
		for(var i=0; i<keys.length; i++) {
			values = values.concat(this.table[keys[i]]);
		}
		
		return values;
	}

	// Copies all of the mappings from the specified Map to this Hashtable These mappings will replace any mappings that this Hashtable had for any of the keys currently in the specified Map. 
	this.putAll = function() {
		var hashTable = arguments[0];
		var keys = hashTable.keys();

		for(var i=0; i<keys.length; i++) {
			this.put(keys[i], hashTable.get(keys[i]));
		}
	}

	// Returns the number of keys in this hashtable. 
	this.size = function() {
		return this.keys().length;
	}

	// Tests if this hashtable maps no keys to values. 
	this.isEmpty = function() {
		return this.keys().length==0;
	}
}


// ----------------------------------------------------------------
function ArrayList() {
	this.table = new Array();

	this.add = function() {
		if( arguments.length==1 ) {
			this.table[ this.table.length ] = arguments[0];
		}
		else if( arguments.length==2 ) {
			this.table.splice(arguments[0],0,arguments[1]);
		}
	}

	this.addAll = function() {
		if( arguments.length==1 ) {
			var list = arguments[0];
			for(var i=0; i<list.size(); i++) {
				this.table[ this.table.length ] = list.get(i);
			}
		}
		else if( arguments.length==2 ) {
			var index = arguments[0]; 
			var list = arguments[1];
			for(var i=0; index<this.table.length && i<list.size(); i++) {
				this.table.splice(index+i,0,list.get(i));
			}
		}
	}

	this.clear = function() {
		this.table = new Array();
	}

	this.remove = function() {
		if( arguments.length==1 ) {
			this.table.splice(arguments[0],1);
		}
		else if( arguments.length==2 ) {
			this.table.splice(arguments[0],arguments[1]);
		}
	}

	this.indexOf = function() {
		if( arguments.length<1 ) {
			return -1;
		}

		for(var i=0; i<this.table.length; i++) {
			if( arguments[0]==this.table[i] ) {
				return i;
			}
		}

		return -1;
	}

	this.contains = function() {
		if( arguments.length<1 ) {
			return false;
		}

		return this.indexOf(arguments[0])!=-1;
	}

	this.isEmpty = function() {
		return this.table.length!=0;
	}

	this.set = function() {
		if( arguments.length==2 ) {
			var index = arguments[0];
			var element = arguments[1];

			if( index<this.table.length ) {
				this.table[index] = element;
			}
		}
	}

	this.get = function() {
		if( arguments.length==1 ) {
			var index = arguments[0];
			if( index < this.table.length ) 
				return this.table[index];
			else
				return null;
		}
	}

	this.toArray = function() {
		return this.table;
	}

	this.size = function() {
		return this.table.length;
	}
	
    this.alert = function() {
		alert( this.table );
	}
}

function toArrayList(arr) {
	var list = new ArrayList();
	for(var i=0; i<arr.length; i++) {
		list.add(arr[i]);
	}
	return list;
}
// ----------------------------------------------------------------
function ArraysClass() {
	this.asList = function() {
		if( arguments.length==1 && arguments[0].constructor==Array ) {
			var a = arguments[0];
			var list = new ArrayList();
			for(var i=0; i<a.length; i++) {
				list.add(a[i]);
			}

			return list;
		}
		
		return null;
	}
}

var Arrays = new ArraysClass();

// -----------------------------------------------------------------
function endsWith(s1, s2) {
    var i;

    return ( (i=s1.indexOf(s2))>=0 && s2.length+i==s1.length );
}
// -----------------------------------------------------------------

function TitleBar(id, title) {
    this.id = id;
    this.title = title;
    this.showBar = ShowTitleBar;
}

function ShowTitleBar() {
/*
    document.writeln('<table border="0" width="100%" cellpadding="0" cellspacing="0" style="height:30px" id="'+this.id+'">');
    document.writeln('<tr>');
    document.writeln('<td style="color:#ffffff;padding-top:8px;background-image:url(\'../../images/task-bar-bg.gif\')">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+this.title+'</td>');
    document.writeln('<td style="height:30px;width:262px;background-image:url(\'../../images/task-bar.gif\')"><br /></td>');
    document.writeln('</tr>');
    document.writeln('</table>');
*/

document.writeln('<table border="0" cellpadding="0" cellspacing="0" width="100%" id="'+this.id+'" >');
document.writeln('<tr> ');
document.writeln('<td height="30"><table border="0" cellspacing="0" cellpadding="0">');
document.writeln('<tr>');
document.writeln('<td width="15" height="30"><img src="../../images/1.gif"/></td>');
document.writeln('<td height="30" background="../../images/3.gif" nowrap><font color="white">'+this.title+'</font></td>');
document.writeln('<td width="15" height="30"><img src="../../images/2.gif"/></td>');
document.writeln('</tr>');
document.writeln('</table></td><td width="100%" height="30" background="../../images/task-bar.gif">&nbsp;</td>');
document.writeln('</tr>');
document.writeln('</table>');

}

function switchTag(tag,content)
{
    for(var i=1; i <6; i++)
    {
        if ("tag"+i==tag)
        {
     
           window.document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;
            window.document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
        }else{
   
            window.document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";
      
            window.document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";

        }
        
        
        if ("content"+i==content)
        {
       
            window.document.getElementById(content).className="";
        }else{

            window.document.getElementById("content"+i).className="hidecontent";
        }

        window.document.getElementById("content").className=content;
    }
}

function popupEmployeeSearch(cntId, cntName){
    window.open('../Commons/EmployeeSearchForm.aspx?CONTROL_ID='+cntId+"&CONTROL_NAME="+cntName,'EmployeeSearchForm','scrollbars,resizable,height=460,width=500')
}
function popupMemberSearch(cntId, cntName){
    window.open('../Commons/MemberSearchForm.aspx?CONTROL_ID='+cntId+"&CONTROL_NAME="+cntName,'MemberSearchForm','scrollbars,resizable,height=460,width=500')
}
function popupTeacherSearch(cntId, cntName){
    window.open('../Commons/TeacherSearchForm.aspx?CONTROL_ID='+cntId+"&CONTROL_NAME="+cntName,'MemberSearchForm','scrollbars,resizable,height=460,width=500')
}
// <%-- Add by zx 2007/11/02 --%>
// call ajax method commom
// EmployeeName
function showEmployeeName(source,target){        
    var objSource = document.getElementById(source);       
    var objTarget = document.getElementById(target);   
    objTarget.style.color='red';
    objTarget.value = "Search...";  
    objTarget.style.color='black';  
    objTarget.value = CommonAjaxUtils.GetEmployeeNameById(objSource.value).value;
}
// MemberName
function showMemberName(source,target){      
    var objSource = document.getElementById(source);       
    var objTarget = document.getElementById(target);  
    objTarget.style.color='red';
    objTarget.value = "Search...";  
    objTarget.style.color='black';
    objTarget.value = CommonAjaxUtils.GetMemberNameById(objSource.value).value;
}
// TeacherName
function showTeacherName(source,target){        
    var objSource = document.getElementById(source);       
    var objTarget = document.getElementById(target);   
    objTarget.style.color='red';
    objTarget.value = "Search...";  
    objTarget.style.color='black';  
    objTarget.value = CommonAjaxUtils.GetTeacherNameById(objSource.value).value;
}
//memberInfo
function showMemberInfo(source,target,target2){      
    var objSource = document.getElementById(source);       
    var objTarget = document.getElementById(target);  
    var objTarget2 = document.getElementById(target2);  
    
    objTarget.style.color='red';
    objTarget.value = "Search...";  
    objTarget.style.color='black';
    var obj = CommonAjaxUtils.GetMemberInfoById(objSource.value).value;
    if(obj != null && typeof(obj) == "object")
    {  
    objTarget.value = obj.NameC;
    if(obj.ApartmentNo == null)
    {objTarget2.value = "";}
    else
    {objTarget2.value = obj.ApartmentNo;}

    
    }
   
}



//
    function openPersonDetails(memberNo){
            var url  = "../search/PersonInfoForm.aspx";          	        
	        var prm  = "?MEMBER_NO=" + memberNo;	        
	        url += prm;	        
	        var win = window.open(url,"PersonInfoForm",'scrollbars,resizable,height=790,width=930');	        
	        win.focus();
        }
        
        //
       function selectAll()
    {
        for(i=0; i<aspnetForm.elements.length; i++)
        {
            
            var e = aspnetForm.elements[i];
            if (e.type == "checkbox" && !e.checked)
            {
                e.checked=true;
                if( e.onchange ) e.onchange();
            }
        }
    }
     function cancelAll()
    {
        for(i=0; i<aspnetForm.elements.length; i++)
        {
            
            var e = aspnetForm.elements[i];
            if (e.type == "checkbox" && e.checked)
            {
                e.checked=false;
                if( e.onchange ) e.onchange();
            }
        }
    }